package cn.zh.npro.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

import cn.zh.npro.Item.ClevItem;
import cn.zh.npro.R;

/**
 * Created by WYN on 2018/3/13 0013.
 */

public class CeAdapter extends BaseAdapter {
    Context context;
    ArrayList<ClevItem> arrayList;
    String txt;
    LayoutInflater inflater;
   public CeAdapter(Context context,ArrayList<ClevItem> arrayList,String txt){
       this.context=context;
       this.arrayList=arrayList;
       this.txt=txt;
       inflater=LayoutInflater.from(context);
       }




    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return arrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
       Holder holder=null;
       if (null==view){
           holder=new Holder();
           view=inflater.inflate(R.layout.cin_layout,null,false);
           holder.ntxt=view.findViewById(R.id.ntxt);
           holder.imag=view.findViewById(R.id.imag);
           view.setTag(holder);
         }else {
           holder= (Holder) view.getTag();
         }
         holder.ntxt.setText(arrayList.get(i).getCustomerLevelTitle());
         if (txt.equals(arrayList.get(i).getCustomerLevelTitle())){
             holder.imag.setVisibility(View.VISIBLE);
         }else {
             holder.imag.setVisibility(View.GONE);
         }


        return view;
    }




    public class Holder{
       TextView ntxt;
       ImageView imag;
    }

  }
